#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2020/10/11 0011 20:00
# @Email : gxfana.2019@gmail.com
from django.utils.deprecation import MiddlewareMixin
from django.shortcuts import redirect


class LoginMiddleWare(MiddlewareMixin):

    def process_request(self, request):
        if request.path in ["/login/", "/reg/", "/get_code_img/"]:    # 不拦截的路径
            return None
        if not request.user.id:
            return redirect("/login/")
